/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.ufrgs.inf.prav.interop.jsf.components;

import br.ufrgs.inf.prav.interop.resource.ClientType;
import br.ufrgs.inf.prav.interop.util.HTTPClientIdentifier;
import java.io.IOException;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;

/**
 *
 * @author Fernando Arena Varella
 * @version 1.0
 */
public class DocTypeComponent extends PravBaseComponent {

    public static final String COMPONENT_FAMILY = "PRAV_DOCTYPE";
    public static final String COMPONENT_TYPE = "PRAV_DOCTYPE";

    public DocTypeComponent(){

    }

    @Override
    public void encodeBegin(FacesContext context) throws IOException {
		ResponseWriter writer =
			context.getResponseWriter();
        ClientType clientType = HTTPClientIdentifier.getClientType();
        switch (clientType){
            case MOBILE: writer.startElement("!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\" " +
                    "\"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\"", this);
                    break;
            case WEB:
            default: writer.startElement("!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" " +
                "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"", this);
        }
	}

    @Override
    public void encodeEnd(FacesContext context)
            throws IOException {
//        ResponseWriter writer = context.getResponseWriter();
//        writer.endElement("DOCTYPE");
//        writer.flush();
//        return;
    }


    // <editor-fold defaultstate="collapsed" desc="Getters And Setters">
    // </editor-fold>

}
